When you first create a sound channel with SndNewChannel , you can request that the channel have certain characteristics as specified by a sound channel initialization parameter. For example, to indicate that you want to allocate a channel capable of producing stereo sound, you might use the following code:
myErr := SndNewChannel(mySndChan, sampledSynth, initStereo, NIL);
These are the currently recognized constants for the sound channel initialization parameter.
CONST
initChanLeft = $0002; {left stereo channel}
initChanRight = $0003; {right stereo channel}
waveInitChannel0 = $0004; {wave-table channel 0}
waveInitChannel1 = $0005; {wave-table channel 1}
waveInitChanne12 = $0006; {wave-table channel 2}
waveInitChannel3 = $0007; {wave-table channel 3}
initMono = $0080; {monophonic channel}
initStereo = $00C0; {stereo channel}
initMACE3 = $0300; {3:1 compression}
initMACE6 = $0400; {6:1 compression}
initNoInterp = $0004; {no linear interpolation}
initNoDrop = $0008; {no drop-sample conversion}
See "Channel Initialization Parameters" for a complete description of these constants.
Some Macintosh computers play only the left channel of stereo sounds out the internal speaker. Other machines (for example, the Macintosh SE/30 and Macintosh IIsi) mix both channels together before sending a signal to the internal speaker. You can use the Gestalt function to determine if a particular machine mixes both left and right channels to the internal speaker. All Macintosh computers except the Macintosh SE and the Macintosh Plus, however, play stereo signals out the headphone jack.
The initialization parameters are additive. To initialize a channel for stereo sound with no linear interpolation, simply pass an initialization parameter that is the sum of the desired characteristics, as follows:
myErr := SndNewChannel(mySndChan, sampledSynth,
initStereo+initNoInterp, NIL);
A call to SndNewChannel is really only a request that the Sound Manager open a channel having the desired characteristics. It is possible that the parameters requested are not available. In that case, SndNewChannel returns a notEnoughHardwareErr error. In general, you should pass 0 as the third parameter to SndNewChannel unless you know exactly what kind of sound is to be played.
You can alter certain initialization parameters, even while a channel is actively playing a sound, by issuing the reInitCmd command. For example, you can change the output channel from left to right, as shown in Listing 1-12 .
Listing 12 Reinitializing a sound channel
VAR
mySndCmd: SndCommand;
mySndChan: SndChannelPtr;
myErr: OSErr;
.
.
.
mySndCmd.cmd := reInitCmd;
mySndCmd.param1 := 0; {unused}
mySndCmd.param2 := initChanRight; {new init parameter}
myErr := SndDoImmediate(mySndChan, mySndCmd);
The reInitCmd command accepts the initNoInterp constant to toggle linear interpolation on and off; it should be used with noncompressed sounds only. If an noncompressed sound is playing when you send a reInitCmd command with this constant, linear interpolation begins immediately. You can also pass initMono , initChanLeft , or initChanRight to pan to both channels, to the left channel, or to the right channel. This affects only monophonic sounds. The Sound Manager remembers the settings you pass and applies them to all further sounds played on that channel.
| Previous | Chapter contents | Chapter top | Section top | Next |